An assorted collection of tips and hints. The latest additions and comments will be in this color.
And so it was in the first version of this CD-ROM. With the 4.x and 5.x releases of both major browsers, however, this isn't the problem it once was. Microsoft's Internet Explorer can run scripts of 10,000 lines with no difficulties whatsoever.
You might run into
the occasional script engine bug these days, but it will be a rare thing.
Nothing has changed since this was first written.
Although the standard sounds formats are well documented and ubiquitous,
the browsers still insist on dealing with them through meals of add-ons
and plugins. We have no idea why native support for the WAV and MIDI
formats hasn't been added--especially since Microsoft was trying so hard
to make Internet Explorer the operating system shell in Windows 98.
Although there won't be any versions of Netscape 2.0 running on the web
these days (and if there are, too bad for them), it's good practice to make sure you
specify the height and width of images. The rendering engines can work
much more quickly if they know how large the images are.
alert()
"
as you would use C's printf()
to keep track of your place and discover where your scripts
are going wrong. Be careful, though! Avoid infinite loops
or you may have to reboot the computer.
Nothing beats a little "printf debugging." It's no longer necessary
to reboot the computer in when the infinite loop occurs, though. Use window.confirm()
instead of alert()
. It has the same syntax as the alert
. The confirmation dialog has a cancel button, which
causes the function call to return false
. Use that return value to signal
a break from the loop.
We're happy to report that in most modern cases the error numbers are off by at most one line. It's not a perfect situation, but it's better.
Or the equally viable --i
, which isn't going to confuse the HTML parser.
Some of you are thinking, what about a line like
if(g < --i) CheckSomething()
and all we have to say is, you've got bigger problems than confused a parser if you're coding with that style!
Years of scripting experience have led your co-author to suspect that this may be more trouble than it's worth. With all due respect to Erica, Brook believes that sticking with the double quotes and escaped double quotes pays off in the long run. Alternating single and double quotes in a string make it hard for the maintenance programmers to see what's going on in a script.
A little discipline here pays off in the long haul.
function foo() { var argv=foo.arguments var argc=foo.arguments.length }